﻿#region File Description
//-----------------------------------------------------------------------------
// MessageBoxScreen.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Audio;
#endregion

namespace PokeTD
{
    /// <summary>
    /// A popup message box screen, used to display "are you sure?"
    /// confirmation messages.
    /// </summary>
    class CreditsScreen : GameScreen
    {
        ContentManager content;
        Texture2D backgroundTexture;
        Texture2D backgroundLayer;
        SpriteFont font;

        InputAction inputExit;

        const string text = "Credits\n\n" +
                            "Programmierung:\n" +
                            "Hintergrundbild:\n" + 
                            "Diverse Sprites:\n" +
                            "Highscore-API (Server):\n" +
                            "Hintergrundmusik:\n";
        const string text2 = "\n\n" +
                             "Birne94, Pharao, Delirum\n" +
                             "r92\n" +
                             "Rumo\n" +
                             "The Libertine\n" +
                             "Kevin MacLeod\n";

        public CreditsScreen()
        {
            inputExit = new InputAction(
                new Buttons[] { Buttons.B, Buttons.Back },
                new Keys[] { Keys.Escape },
                true);
        }

        /// <summary>
        /// Loads graphics content for this screen. This uses the shared ContentManager
        /// provided by the Game class, so the content will remain loaded forever.
        /// Whenever a subsequent MessageBoxScreen tries to load this same content,
        /// it will just get back another reference to the already loaded data.
        /// </summary>
        public override void Activate(bool instancePreserved)
        {
            if (!instancePreserved)
            {
                ContentManager content = ScreenManager.Game.Content;
                font = content.Load<SpriteFont>("SegoeUIMono");
                backgroundTexture = content.Load<Texture2D>("Menu\\background");
                backgroundLayer = new Texture2D(ScreenManager.Game.GraphicsDevice, 1, 1);
                backgroundLayer.SetData<Color>(new Color[] { new Color(0, 0, 20, 200) });
            }
        }


        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            if (inputExit.Evaluate(input))
                ExitScreen();
        }

        #region Draw


        /// <summary>
        /// Draws the message box.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
            SpriteFont font = ScreenManager.Font;

            // Center the message text in the viewport.
            Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
            Rectangle fullscreen = new Rectangle(0, 0, viewport.Width, viewport.Height);

            spriteBatch.Begin();

            spriteBatch.Draw(backgroundTexture, fullscreen,
                             new Color(TransitionAlpha, TransitionAlpha, TransitionAlpha));
            spriteBatch.Draw(backgroundLayer, new Rectangle(40, 40, viewport.Width - 80, viewport.Height - 80),
                             Color.White);

            spriteBatch.DrawString(font, text, new Vector2(50, 50), Color.White);
            spriteBatch.DrawString(font, text2, new Vector2(450, 50), Color.White);

            spriteBatch.End();
        }


        #endregion
    }
}
